//index.js  
//获取应用实例  
var app = getApp();
var common = require("../../utils/common.js");
var that
Page({
  data: {
    s_position:0,  //当前滚轴位置
    map_hidden:true,
    fixed_hidden: false, 
    // tab切换  
    currentTab: 0,
    orderList0: [1,1,1,1,1,1],
    orderList1: [],
    h: 0,
    house_type:"",
    h_phone:"",
    h_business_hours:"",
    h_address:"",
    banner: [], //链接图及关联信息
    service:"",  //服务项目
    ser_id:"", //从申请会员传回的服务id
    shop_point:"", //店铺经纬度
   
    shops: []   
  },
  onLoad: function (options) {  

    that=this;
    that.get_shop_msg(); //获取店铺信息
    wx.getSystemInfo({
      success: function (res) {
        that.setData({
          h: res.windowHeight,
          
        });
      }
    });   
    

    this.setData({ currentTab: 0,});
   
  },
  onShow: function () {
  
   
  },
 
 


  

  select_shop: function (e) {//跳转到店铺首页
    var shop_id = e.currentTarget.dataset.id;
    wx.setStorageSync('shop_id', shop_id);
    wx.setStorageSync('shop_index',e.currentTarget.dataset.index);
    //console.info(e.currentTarget.dataset.id);
    wx.reLaunch({
      url: './home'
    })   
  },
 
  get_shop_msg: function () {
  
    app.req("get_shop.html", {}, function (res) {
      var shop_arr = [];
      if (res.status == "success") {
        for (var shop in res.mess) {
          shop_arr.push(res.mess[shop]);
          
        }

      
        that.setData({ shops: res.mess });
      } else if (res.status == "error") {
        app.toast_up(res.mess)
      } else {
        app.modal("错误提示", "网络错误，是否重试？", function (re) {
          if (re) {
            that.get_service_msg()
          }
        })
      }
    })
  },
 


  map_adr:function(e){//点击地图跳到大地图界面
    wx.navigateTo({
      url: './map_adr?point='+e.currentTarget.dataset.point,
    })
  },
 

  img_lianjie:function(e){
    var i = e.currentTarget.dataset.idx;
    switch(that.data.banner[i].type){
      case 0: //只显示图片
        
        break;
      case 1: //跳转房间详情
        wx.navigateTo({
          url: './house_detail?house_id=' + that.data.banner[i].value
        });
      break;
      case 2://跳转商品详情
        wx.navigateTo({
          url: '../shop/goods_detail?productId=' + that.data.banner[i].value
        });
      break;
      case 3://跳转外部
        wx.navigateTo({
          url: './to_web?path=' + that.data.banner[i].value
        });
      break;
    }
    
  },
  onGotUserInfo: function (e) {
    console.info(e.currentTarget);
    var shop_id = e.currentTarget.dataset.id;
    var point   = e.currentTarget.dataset.point;
    wx.setStorageSync('point', point);
    wx.setStorageSync('shop_id', shop_id);
    wx.setStorageSync('shop_index', e.currentTarget.dataset.index);
    //console.info(e.currentTarget.dataset.id);
   
    app.globalData.userInfo = e.detail.userInfo;  
    app.data.signature = e.detail.signature;
    wx.setStorageSync('userInfo_rawData', e.detail.rawData);
    wx.setStorageSync('signature', e.detail.signature);
    console.log(e.detail);
    //console.log(e.detail.rawData);
    wx.reLaunch({
      url: './home'
    });
  },


})